<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class EnableCorsMiddleWare
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request, Closure $next)
    {
        $host=["*"];
        // $response=response()->withHeaders([
        //     "Access-Control-Request-Method"=>['OPTIONS','GET','POST'],
        //     "Access-Control-Allow-Origin"=>implode(",",$host),
        //     "Access-Control-Allow-Headers"=>'DNT,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization,token'
        // ]);
        // if($request->getMethod() === 'OPTIONS'){
        //     return $response;
        // }
        return $next($request);
    }
}
